// 封装文章相关请求
import { request } from "@/utils"

// 获取频道列表
export const getChannelAPI = () => {
  return request({
    method: 'get',
    url: '/channels',
  })
}

// 提交文章表单
export const createArticleAPI = (data) => {
  return request({
    method: 'post',
    url: '/mp/articles?draft=false',
    data
  })
}

// 获取文章列表
export const getArticleListAPI = (params) => {
  return request({
    method: 'get',
    url: '/mp/articles',
    params
  })
}

// 删除文章
export const delArticleAPI = (id) => {
  return request({
    method: 'delete',
    url: `/mp/articles/${id}`,
  })
}

// 获取文章详情
export const getArticleByIdAPI = (id) => {
  return request({
    method: 'get',
    url: `/mp/articles/${id}`,
  })
}

// 更新文章表单
export const updateArticleAPI = (data) => {
  return request({
    method: 'put',
    url: `/mp/articles/${data.id}?draft=false`,
    data
  })
}
